package com.example.demo.config;

import com.example.demo.common.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理
 *
 * @author CY
 * @date 2023/03/14 17:01
 **/
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public AjaxResult getError(Exception e) {
        return AjaxResult.fail(-1, e.getMessage());
    }


}
